import { useI18n } from "vue-i18n";

export default function useFormatData(data: any, apiData = []) {
  // 使用 useI18n 钩子
  const { t, locale } = useI18n();
  const formatData = ref<any>([]);
  const handleFormatData = () => {
    console.log("handleFormatData", data, t("countTask.renWuMingCheng"));
    data.list.forEach((item: any) => {
      
      item.details.list = [
        {
          label: t("countTask.renWuMingCheng"),
          text: "抽盘手机"
        },
        {
          label: t("countTask.panDianRiQi"), //盘点日期：
          text: "2024-06-05"
        },
        {
          label: t('countTask.panDianRen'),
          text: "全盘"
        }
      ]
    });

    formatData.value = data;
    // formatData.value = data.map((item) => {
    //   return {
    //     ...item,
    //     ...apiData.find((apiItem) => apiItem.id === item.id),
    //   };
    // });
  };
  watchEffect(() => {
    console.log("🚀 ~ watchEffect ~ watchEffect:");
    handleFormatData();
  });
  return [formatData, handleFormatData];
}
